﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;

namespace WebSite.admin.pay
{
    public partial class payment : System.Web.UI.Page
    {
        // Methods
        private void Bind()
        {
            string sql = "select * from DB_Pay";
            this.GridView1.DataSource = SQLAccess.GreatDs(sql);
            this.GridView1.DataBind();
            if ((base.Request.QueryString["pid"] != null) && (base.Request.QueryString["action"] != null))
            {
                if (base.Request.QueryString["action"].ToString() == "install")
                {
                    SQLAccess.DoSql("update DB_Pay set flag=1 where payid=" + base.Request.QueryString["pid"].ToString() + "");
                }
                else if (base.Request.QueryString["action"].ToString() == "uninstall")
                {
                    SQLAccess.DoSql("update DB_Pay set flag=0 where payid=" + base.Request.QueryString["pid"].ToString() + "");
                }
                base.Response.Write("<script language='javascript'>window.location.href='payment.aspx';</script>");
                base.Response.End();
            }
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if ((e.Row.RowType == DataControlRowType.Header) || (e.Row.RowType == DataControlRowType.DataRow))
            {
                e.Row.Cells[1].Width = 300;
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=\"" + e.Row.Style["BACKGROUND-COLOR"] + "\"");
                    e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor=\"#efefef\"");
                    if (e.Row.Cells[5].Text == "1")
                    {
                        e.Row.Cells[7].Text = "<a href='payment.aspx?action=uninstall&amp;pid=" + e.Row.Cells[6].Text.ToString() + "'>卸载</a> <a href='" + e.Row.Cells[4].Text.ToString() + "?pid=" + e.Row.Cells[6].Text.ToString() + "'>编辑</a>";
                    }
                }
                else
                {
                    DataControlRowType rowType = e.Row.RowType;
                }
                e.Row.Cells[4].Visible = false;
                e.Row.Cells[5].Visible = false;
                e.Row.Cells[6].Visible = false;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Session["Adminlogin"] == null)
            {
                base.Response.Write("<script language=javascript>window.top.location.href='../login.aspx';</script>");
                base.Response.End();
            }
            if (!base.IsPostBack)
            {
                this.Bind();
            }
        }



    }
}